#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@fileName      : main.py
@desc          : 
@dateTime      : 2020/11/25 20:33:47
@author        : 5km
@contact       : 5km@smslit.cn
'''

from flask_cors import CORS
from flask import Flask, request


app = Flask(__name__)
cors = CORS(app=app, supports_credentials=True)


@app.route('/')
def index():
    return 'hello, demo!'


@app.route('/api/add', methods=['POST'])
def add():
    data = request.json
    augend = data.get('augend')
    addend = data.get('addend')
    if type(augend) != int or type(addend) != int:
        return {'message': 'The number is not int one!'}, 400
    return {
        "result": augend + addend
    }
